package Dungeon;

import static org.junit.Assert.*;
import SquarePackage.Direction;
import org.junit.Before;
import org.junit.Test;

	
public class DimensionTest {

	private Dimension testDimension1;
	private Dimension testDimension2;
	private Dimension testDimension3;
	private Dimension testDimension4;
	private Dimension testDimension5;
	private Dimension testDimension6;
	private Dimension testDimension7;
	private Dimension testDimension11;
	@Before
    public void setUp() throws Exception {
            testDimension1= new Dimension(0,10,0);
            testDimension11= new Dimension(0,10,1);
            testDimension2 = new Dimension(0,11,0);
            testDimension3 = new Dimension(1, 11, 0);
            testDimension4 = new Dimension(1, 12, 0);
            testDimension5 = new Dimension(1, 10, 0);
            testDimension6 = new Dimension(1, 1, 1);
            testDimension7 = new Dimension(2, 1, 1);

    }
    @Test
    public void getDirectionOfEastTest(){
            assertEquals(Direction.EAST,testDimension6.getNeigbourDirection(testDimension7));
    }
    @Test
    public void getDirectionOfWestTest(){
            assertEquals(Direction.WEST,testDimension7.getNeigbourDirection(testDimension6));
    }
    @Test
    public void getDirectionOfCeilingTest(){
            assertEquals(Direction.CEILING,testDimension1.getNeigbourDirection(testDimension11));
    }
    @Test
    public void getDirectionOfSouthTest(){
            assertEquals(Direction.SOUTH,testDimension1.getNeigbourDirection(testDimension2));
    }
    @Test
    public void getDirectionOfNorthTest(){
            assertEquals(Direction.NORTH,testDimension4.getNeigbourDirection(testDimension3));
    }
    @Test
    public void getDirectionOfFloorTest(){
            assertEquals(Direction.FLOOR,testDimension11.getNeigbourDirection(testDimension1));
    }
    @Test
    public void getDirectionOfIllegalTest(){
            assertEquals(null,testDimension1.getNeigbourDirection(testDimension7));
    }
    @Test
    public void equalsTest(){
            Dimension tempTestDimension=new Dimension(0,10,0);
            assertTrue(tempTestDimension.equals(testDimension1));
            assertFalse(testDimension1.equals(testDimension4));
    }
    public void equals2Test(){
            Dimension tempTestDimension1=new Dimension(1,1,1);
            Dimension tempTestDimension2=new Dimension(1,1,1);
            Dimension tempTestDimension3=new Dimension(1,1,1);
            assertTrue(tempTestDimension1.equals(tempTestDimension1));
            assertTrue(tempTestDimension2.equals(tempTestDimension1));
            assertTrue(tempTestDimension1.equals(tempTestDimension2));
            assertTrue(tempTestDimension1.equals(tempTestDimension3));
            assertTrue(tempTestDimension2.equals(tempTestDimension3));
            assertTrue(tempTestDimension3.equals(tempTestDimension2));
            assertTrue(tempTestDimension3.equals(tempTestDimension3));
            assertTrue(tempTestDimension3.equals(tempTestDimension1));
    }
    @Test	(expected = IllegalArgumentException.class)
    public void constructorIllegalTest(){
            Dimension testDim1=new Dimension(Integer.MAX_VALUE+100,3,2);
    }
    @Test	(expected = IllegalArgumentException.class)
    public void constructorIllegal2Test(){
            Dimension testDim1=new Dimension(-123,3,2);
    }
    @Test
    public void getDimensionInLegalTest(){
            assertEquals(testDimension1,testDimension11.getDimensionIn(Direction.FLOOR));
    }
    @Test
    public void getDimensionInLegal1Test(){
            assertEquals(testDimension2,testDimension1.getDimensionIn(Direction.SOUTH));
    }
    @Test
    public void getDimensionInLegal2Test(){
            assertEquals(testDimension5,testDimension1.getDimensionIn(Direction.EAST));
    }
    @Test
    public void getDimensionInLegal3Test(){
            assertEquals(testDimension6,testDimension7.getDimensionIn(Direction.WEST));
    }
    @Test
    public void getDimensionInLegal4Test(){
            assertEquals(testDimension11,testDimension1.getDimensionIn(Direction.CEILING));
    }
    @Test
    public void getDimensionInLegal5Test(){
            assertEquals(testDimension1,testDimension2.getDimensionIn((Direction.NORTH)));
    }
    @Test
    public void getDimensionInIllegalTest(){
            assertEquals(null,testDimension1.getDimensionIn(Direction.WEST));
    }
    @Test
    public void getDimensionInIllegal2Test(){
            assertEquals(null,testDimension1.getDimensionIn((Direction.FLOOR)));
    }






}

